<?php
//register asset files
//register javascript
//extract variables
//$sender = $_REQUEST['message_sender'];

$operation = Blyn::app()->getActiveOperation();

if (isset($_REQUEST['MessageFormModel'])) {
    $receiver = $_REQUEST['MessageFormModel']['sendTo'];
    $messageData = $_REQUEST['MessageFormModel']['messageBody'];    
    
    $operation->getMessenger()->sendMessage($messageData, $receiver);    

    //$opContract = new BOCSpaceMessage();

    //$opContract->sendOperationRequest(
    //        array('name' => BOCSpaceMessage::Operation_SendMessage, 'data' => array('message' => $messageData)), $receiver, NULL);
}
?>

<style TYPE="text/css">
    .messagebox {
        padding: 8px;
        background-color: #F7F7F9;
        border: 1px solid #E1E1E8;
    }
</style>
<?php
$messages = $operation->getMessenger()->receiveMessages();
foreach ($messages as $message) {
    $medias = $message->getMediaManager()->getMedias();
    foreach ($medias as $media) {
//for ($index = 0; $index < 3; $index++) {
    ?>
    <div class="row-fluid" style="margin-top: 15px">
        <div class="span2"><a title="hi" href="#" accesskey="q" class="avatar" boss="btnWideSideHeadImage" hidefocus="true">
                <img src="<?php echo Yii::app()->request->baseUrl; ?>/images/qie.jpg" width="50" height="50"></a></div>
        <div class="span10 messagebox" style="margin-left: -10px;" >
            <?php echo $media->getContent(); ?>
        </div>
    </div>
<?php } } ?>
